﻿using System;
using System.Collections.Generic;
using System.Configuration;
using System.Linq;
using System.Security.Permissions;
using System.Web;

namespace Galaktika.BI.Silverlight.ClientApp.Web.Configuration
{
    [AspNetHostingPermission(SecurityAction.LinkDemand, Level = AspNetHostingPermissionLevel.Minimal)]
    public class DataServiceCommand : ConfigurationElement
    {
        private static readonly ConfigurationPropertyCollection m_Props;
        private static readonly ConfigurationProperty m_TypeProp;
        private static readonly ConfigurationProperty m_IdProp;
        static DataServiceCommand()
        {
            m_TypeProp = new ConfigurationProperty("type", typeof(string), null, null, new StringValidator(1), ConfigurationPropertyOptions.IsRequired);
            m_IdProp = new ConfigurationProperty("id", typeof(string), null, null, new StringValidator(1), ConfigurationPropertyOptions.IsKey | ConfigurationPropertyOptions.IsRequired);
            m_Props = new ConfigurationPropertyCollection();
            m_Props.Add(m_TypeProp);
            m_Props.Add(m_IdProp);
        }

        public DataServiceCommand()
        {
        }

        [ConfigurationProperty("type", IsRequired = true, DefaultValue = ""), StringValidator(MinLength = 1)]
        public string Type { get; set; }

        [ConfigurationProperty("id", IsRequired = true, IsKey=true, DefaultValue = ""), StringValidator(MinLength = 1)]
        public string Id { get; set; }

        protected override ConfigurationPropertyCollection Properties
        {
            get
            {
                return m_Props;
            }
        }

        //internal Type CommandType
        //{
        //    get
        //    {
        //        return System.Type.GetType(this.Type);
        //    }
        //}
    }
}
